package com.itheima.d4_map;

import javax.sound.midi.Soundbank;
import java.util.*;

public class MapTest2 {
    public static void main(String[] args) {
        //Map<String,Integer> map =new HashMap<>();//map按照键，无序，不重复，无索引
        Map<String,Integer> map =new LinkedHashMap<>();//map按照键，有序，不重复，无索引

        map.put("手表",100);
        map.put("手表",120);
        map.put("手机",20);
        map.put("Java",2);
        map.put(null,null);
        System.out.println(map);

        System.out.println(map.size());//获取集合的大小

        //map.clear();
        //System.out.println(map);//清空集合

        System.out.println(map.isEmpty());//是否为空

        int v1 = map.get("手表");
        System.out.println(v1);

        System.out.println(map.remove("手表"));
        System.out.println(map);

        System.out.println(map.containsKey("手表"));

        System.out.println(map.containsValue(2));

        Set<String> keys = map.keySet();
        System.out.println(keys);

        Collection<Integer> values = map.values();
        System.out.println(values);

        Map<String,Integer> map1 =new HashMap<>();
        map1.put("java1",10);
        map1.put("java2",20);
        Map<String,Integer> map2 =new HashMap<>();
        map2.put("java1",10);
        map2.put("java2",20);
        map1.putAll(map2);
        System.out.println(map1);
        System.out.println(map2);
    }
}
